package com.lx.model;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

public class PrintOrderInfo {
    private Long id;

    private Long shopId;

    private String orderSn;

    private String tableNo;

    private String tableName;

    private Integer orderType;

    private Date orderTime;

    private Integer personNum;

    private Date createTime;

    private Date updateTime;

    private BigDecimal orderPrice;

    private BigDecimal memberPrice;

    private BigDecimal couponPrice;

    private BigDecimal actualPrice;

    private List<PrintOrderDish> dishs;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getShopId() {
        return shopId;
    }

    public void setShopId(Long shopId) {
        this.shopId = shopId;
    }

    public String getOrderSn() {
        return orderSn;
    }

    public void setOrderSn(String orderSn) {
        this.orderSn = orderSn == null ? null : orderSn.trim();
    }

    public String getTableNo() {
        return tableNo;
    }

    public void setTableNo(String tableNo) {
        this.tableNo = tableNo == null ? null : tableNo.trim();
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName == null ? null : tableName.trim();
    }

    public Integer getOrderType() {
        return orderType;
    }

    public void setOrderType(Integer orderType) {
        this.orderType = orderType;
    }

    public Date getOrderTime() {
        return orderTime;
    }

    public void setOrderTime(Date orderTime) {
        this.orderTime = orderTime;
    }

    public Integer getPersonNum() {
        return personNum;
    }

    public void setPersonNum(Integer personNum) {
        this.personNum = personNum;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public BigDecimal getOrderPrice() {
        return orderPrice;
    }

    public void setOrderPrice(BigDecimal orderPrice) {
        this.orderPrice = orderPrice;
    }

    public BigDecimal getMemberPrice() {
        return memberPrice;
    }

    public void setMemberPrice(BigDecimal memberPrice) {
        this.memberPrice = memberPrice;
    }

    public BigDecimal getCouponPrice() {
        return couponPrice;
    }

    public void setCouponPrice(BigDecimal couponPrice) {
        this.couponPrice = couponPrice;
    }

    public BigDecimal getActualPrice() {
        return actualPrice;
    }

    public void setActualPrice(BigDecimal actualPrice) {
        this.actualPrice = actualPrice;
    }

    public List<PrintOrderDish> getDishs() {
        return dishs;
    }

    public void setDishs(List<PrintOrderDish> dishs) {
        this.dishs = dishs;
    }

    @JSONField(name = "orderTimeStr")
    public String getOrderTimeStr(){
        String odt = "";
        if (orderTime!=null){
            odt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(orderTime);
        }
        return odt;
    }

    static public void main(String[] args){
        String msg = "{\n" +
                "shopId:21,\n" +
                "orderSn:\"sn2132131\",\n" +
                "tableNo:\"TB01\",\n" +
                "tableName:\"餐桌01\",\n" +
                "orderType:1,\n" +
                "orderTime:\"2020-05-10 12:11:11\",\n" +
                "personNum:1,\n" +
                "dishs:[\n" +
                "{\n" +
                "goodsId:1,\n" +
                "goodsName:\"测试菜01\",\n" +
                "price:1.0,\n" +
                "productId:1,\n" +
                "productName:\"测试菜01\",\n" +
                "productPrice:1.0,\n" +
                "number:1,\n" +
                "specifications:\"抄\",\n" +
                "dishUnitName:\"f份\"\n" +
                "}\n" +
                "],\n" +
                "orderPrice:1.0,\n" +
                "memberPrice:1.0,\n" +
                "couponPrice:1.0,\n" +
                "actualPrice:1.0\n" +
                "\n" +
                "}";
        PrintOrderInfo info = JSONObject.toJavaObject(JSONObject.parseObject(msg), PrintOrderInfo.class);
        System.out.println(JSONObject.toJSONString(info));
    }
}